
package py.una.pol.raphapy.autoventas.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Rafael E. Benegas
 */
@Entity
@Table(name = "tipo_telefono")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TipoTelefono.findAll", query = "SELECT t FROM TipoTelefono t"),
    @NamedQuery(name = "TipoTelefono.findByCodTipTel", query = "SELECT t FROM TipoTelefono t WHERE t.codTipTel = :codTipTel"),
    @NamedQuery(name = "TipoTelefono.findByDesTipTel", query = "SELECT t FROM TipoTelefono t WHERE t.desTipTel = :desTipTel")})
public class TipoTelefono implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4)
    @Column(name = "cod_tip_tel")
    private String codTipTel;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "des_tip_tel")
    private String desTipTel;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codTipTel")
    private Collection<Telefono> telefonoCollection;

    public TipoTelefono() {
    }

    public TipoTelefono(String codTipTel) {
        this.codTipTel = codTipTel;
    }

    public TipoTelefono(String codTipTel, String desTipTel) {
        this.codTipTel = codTipTel;
        this.desTipTel = desTipTel;
    }

    public String getCodTipTel() {
        return codTipTel;
    }

    public void setCodTipTel(String codTipTel) {
        this.codTipTel = codTipTel;
    }

    public String getDesTipTel() {
        return desTipTel;
    }

    public void setDesTipTel(String desTipTel) {
        this.desTipTel = desTipTel;
    }

    @XmlTransient
    public Collection<Telefono> getTelefonoCollection() {
        return telefonoCollection;
    }

    public void setTelefonoCollection(Collection<Telefono> telefonoCollection) {
        this.telefonoCollection = telefonoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codTipTel != null ? codTipTel.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof TipoTelefono)) {
            return false;
        }
        TipoTelefono other = (TipoTelefono) object;
        if ((this.codTipTel == null && other.codTipTel != null) || (this.codTipTel != null && !this.codTipTel.equals(other.codTipTel))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.desTipTel;
    }
    
}
